package com.dyc.WelcomeWidget;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

import com.dyc.MainActivity;
import com.dyc.R;
import com.dyc.Utils.SharedUtils;

import org.xutils.x;

import java.util.Timer;
import java.util.TimerTask;

/**
 * @author fangtongle
 * @date 2019/5/10 15:28
 * @desc 启动页Activity
 */
public class WelcomeActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_welcome);
        Timer timer = new Timer();
        timer.schedule(new MyTask(), 3000);
    }

    class MyTask extends TimerTask {
        @Override
        public void run() {
            if (SharedUtils.getWelcomeBoolean(getApplicationContext())) {
                startActivity(new Intent(WelcomeActivity.this, MainActivity.class));
            } else {
                startActivity(new Intent(WelcomeActivity.this, WelcomeGuideActivity.class));
                SharedUtils.putWelcomeBoolean(getBaseContext(), true);
            }
            finish();

        }
    }
}

//        new Handler(new Handler.Callback() {
//            @Override
//            public boolean handleMessage(Message msg) {
//                startActivity(new Intent(WelcomeActivity.this, MainActivity.class));
//                return false;
//            }
//        }).sendEmptyMessageDelayed(0, 3000);
